import 'package:flutter/services.dart';
import 'package:tappay_charge/models/tappay_card_type.dart';
import 'package:tappay_charge/models/tappay_prime.dart';
import 'package:tappay_charge/models/tappay_sdk_common_result.dart';
import 'package:tappay_charge/models/tappay_cart_item.dart';

import 'tappay_charge_platform_interface.dart';

class TappayCharge {
  Future<String?> getPlatformVersion() {
    return TappayChargePlatform.instance.getPlatformVersion();
  }

  Future<TappaySdkCommonResult> initTappay({
    required int appId,
    required String appKey,
    required bool isSandBox
  }) {
    return TappayChargePlatform.instance.initTappay(
      appId: appId,
      appKey: appKey,
      isSandBox: isSandBox
    );
  }

  Future<bool> validateCard({
    required String cardNumber,
    required String dueMonth,
    required String dueYear,
    required String ccv,
  }) {
    return TappayChargePlatform.instance.validateCard(
      cardNumber: cardNumber,
      dueMonth: dueMonth,
      dueYear: dueYear,
      ccv: ccv,
    );
  }

  Future<TappayPrime> getCardPrime({
    required String cardNumber,
    required String dueMonth,
    required String dueYear,
    required String ccv,
  }) {
    return TappayChargePlatform.instance.getCardPrime(
      cardNumber: cardNumber,
      dueMonth: dueMonth,
      dueYear: dueYear,
      ccv: ccv,
    );
  }

  Future<TappaySdkCommonResult> initApplePay({
    required String merchantId,
    required String merchantName,
    String? currencyCode = 'TWD',
    String? countryCode = 'TW',
    List<TappayCardType>? supportedCardTypes,
  }) {
    return TappayChargePlatform.instance.initApplePay(
      merchantId: merchantId,
      merchantName: merchantName,
      currencyCode: currencyCode,
      countryCode: countryCode,
      supportedCardTypes: supportedCardTypes = kDefaultSupportedCardTypes,
    );
  }

  Future<TappayPrime> startApplePay({
    bool isAmountPending = false,
    bool isShowTotalAmount = true,
    required List<TappayCartItem> cartItems,
  }) {
    return TappayChargePlatform.instance.startApplePay(
      isAmountPending: isAmountPending,
      isShowTotalAmount: isShowTotalAmount,
      cartItems: cartItems,
    );
  }

  Future<TappaySdkCommonResult> showApplePayResult({required bool result}) {
    return TappayChargePlatform.instance.showApplePayResult(result: result);
  }

  Future<bool> isLinePayAvailable() {
    return TappayChargePlatform.instance.isLinePayAvailable();
  }

  Future<TappayPrime> getLinePayPrime({required String returnUrl}) {
    return TappayChargePlatform.instance.getLinePayPrime(returnUrl: returnUrl);
  }

  Future<TappayPrime> redirectLinePay({required String paymentUrl}) {
    return TappayChargePlatform.instance.redirectLinePay(paymentUrl: paymentUrl);
  }

  Future<bool> isEasyWalletAvailable() {
    return TappayChargePlatform.instance.isEasyWalletAvailable();
  }

  Future<TappayPrime> getEasyWalletPrime({required String returnUrl}) {
    return TappayChargePlatform.instance.getEasyWalletPrime(returnUrl: returnUrl);
  }

  Future<TappayPrime> redirectEasyWallet({required String paymentUrl}) {
    return TappayChargePlatform.instance.redirectEasyWallet(paymentUrl: paymentUrl);
  }

}
